﻿#include "SVDetectView.h"

SVDetectView::SVDetectView(QWidget *parent)
    : QWidget(parent)
    , mDetectResultLabel(new QLabel(this))
    , mStartButton(new ElaPushButton(QString::fromLocal8Bit("开始检测"), this))
    , mStopButton(new ElaPushButton(QString::fromLocal8Bit("停止检测"), this))
{
    mDetectResultLabel->setAlignment(Qt::AlignCenter);
    mDetectResultLabel->setText(QString::fromLocal8Bit("检测结果显示区域"));
    mDetectResultLabel->setScaledContents(true);

    QHBoxLayout *buttonLayout = new QHBoxLayout;
    buttonLayout->addStretch(3);
    buttonLayout->addWidget(mStartButton, 1);
    buttonLayout->addWidget(mStopButton, 1);

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->addWidget(mDetectResultLabel, 9);
    layout->addLayout(buttonLayout, 1);

    connect(mStartButton, &ElaPushButton::clicked, this, &SVDetectView::startDetection);
    connect(mStopButton, &ElaPushButton::clicked, this, &SVDetectView::stopDetection);
}

void SVDetectView::setDetectResult(const QPixmap &pixmap)
{
    mDetectResultLabel->setPixmap(pixmap);
}
